Integrand size = 30, antiderivative size = 269 \[ \int (e \sec (c+d x))^{-4-n} (a+i a \tan (c+d x))^n \, dx=\frac {i (e \sec (c+d x))^{-4-n} (a+i a \tan (c+d x))^n}{d (4-n)}+\frac {4 i (e \sec (c+d x))^{-4-n} (a+i a \tan (c+d x))^{1+n}}{a d \left (8-6 n+n^2\right )}-\frac {12 i (e \sec (c+d x))^{-4-n} (a+i a \tan (c+d x))^{2+n}}{a^2 d (2-n) (4-n) n}+\frac {24 i (e \sec (c+d x))^{-4-n} (a+i a \tan (c+d x))^{3+n}}{a^3 d (4-n) n \left (4-n^2\right )}-\frac {24 i (e \sec (c+d x))^{-4-n} (a+i a \tan (c+d x))^{4+n}}{a^4 d n \left (64-20 n^2+n^4\right )} \]
I*(e*sec(d*x+c))^(-4-n)*(a+I*a*tan(d*x+c))^n/d/(4-n)+4*I*(e*sec(d*x+c))^(- 4-n)*(a+I*a*tan(d*x+c))^(1+n)/a/d/(n^2-6*n+8)-12*I*(e*sec(d*x+c))^(-4-n)*( a+I*a*tan(d*x+c))^(2+n)/a^2/d/(2-n)/(4-n)/n+24*I*(e*sec(d*x+c))^(-4-n)*(a+ I*a*tan(d*x+c))^(3+n)/a^3/d/(4-n)/n/(-n^2+4)-24*I*(e*sec(d*x+c))^(-4-n)*(a +I*a*tan(d*x+c))^(4+n)/a^4/d/n/(n^4-20*n^2+64)
Time = 1.89 (sec) , antiderivative size = 165, normalized size of antiderivative = 0.61 \[ \int (e \sec (c+d x))^{-4-n} (a+i a \tan (c+d x))^n \, dx=-\frac {i (e \sec (c+d x))^{-n} \left (192-60 n^2+3 n^4+4 n^2 \left (-16+n^2\right ) \cos (2 (c+d x))+n^2 \left (-4+n^2\right ) \cos (4 (c+d x))+128 i n \sin (2 (c+d x))-8 i n^3 \sin (2 (c+d x))+16 i n \sin (4 (c+d x))-4 i n^3 \sin (4 (c+d x))\right ) (a+i a \tan (c+d x))^n}{8 d e^4 (-4+n) (-2+n) n (2+n) (4+n)} \]
((-1/8*I)*(192 - 60*n^2 + 3*n^4 + 4*n^2*(-16 + n^2)*Cos[2*(c + d*x)] + n^2 *(-4 + n^2)*Cos[4*(c + d*x)] + (128*I)*n*Sin[2*(c + d*x)] - (8*I)*n^3*Sin[ 2*(c + d*x)] + (16*I)*n*Sin[4*(c + d*x)] - (4*I)*n^3*Sin[4*(c + d*x)])*(a + I*a*Tan[c + d*x])^n)/(d*e^4*(-4 + n)*(-2 + n)*n*(2 + n)*(4 + n)*(e*Sec[c + d*x])^n)
Time = 1.13 (sec) , antiderivative size = 259, normalized size of antiderivative = 0.96, number of steps used = 10, number of rules used = 10, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.333, Rules used = {3042, 3985, 3042, 3985, 3042, 3985, 3042, 3985, 3042, 3969}
Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.
\(\displaystyle \int (a+i a \tan (c+d x))^n (e \sec (c+d x))^{-n-4} \, dx\) |
\(\Big \downarrow \) 3042 |
\(\displaystyle \int (a+i a \tan (c+d x))^n (e \sec (c+d x))^{-n-4}dx\) |
\(\Big \downarrow \) 3985 |
\(\displaystyle \frac {4 \int (e \sec (c+d x))^{-n-4} (i \tan (c+d x) a+a)^{n+1}dx}{a (4-n)}+\frac {i (a+i a \tan (c+d x))^n (e \sec (c+d x))^{-n-4}}{d (4-n)}\) |
\(\Big \downarrow \) 3042 |
\(\displaystyle \frac {4 \int (e \sec (c+d x))^{-n-4} (i \tan (c+d x) a+a)^{n+1}dx}{a (4-n)}+\frac {i (a+i a \tan (c+d x))^n (e \sec (c+d x))^{-n-4}}{d (4-n)}\) |
\(\Big \downarrow \) 3985 |
\(\displaystyle \frac {4 \left (\frac {3 \int (e \sec (c+d x))^{-n-4} (i \tan (c+d x) a+a)^{n+2}dx}{a (2-n)}+\frac {i (a+i a \tan (c+d x))^{n+1} (e \sec (c+d x))^{-n-4}}{d (2-n)}\right )}{a (4-n)}+\frac {i (a+i a \tan (c+d x))^n (e \sec (c+d x))^{-n-4}}{d (4-n)}\) |
\(\Big \downarrow \) 3042 |
\(\displaystyle \frac {4 \left (\frac {3 \int (e \sec (c+d x))^{-n-4} (i \tan (c+d x) a+a)^{n+2}dx}{a (2-n)}+\frac {i (a+i a \tan (c+d x))^{n+1} (e \sec (c+d x))^{-n-4}}{d (2-n)}\right )}{a (4-n)}+\frac {i (a+i a \tan (c+d x))^n (e \sec (c+d x))^{-n-4}}{d (4-n)}\) |
\(\Big \downarrow \) 3985 |
\(\displaystyle \frac {4 \left (\frac {3 \left (-\frac {2 \int (e \sec (c+d x))^{-n-4} (i \tan (c+d x) a+a)^{n+3}dx}{a n}-\frac {i (a+i a \tan (c+d x))^{n+2} (e \sec (c+d x))^{-n-4}}{d n}\right )}{a (2-n)}+\frac {i (a+i a \tan (c+d x))^{n+1} (e \sec (c+d x))^{-n-4}}{d (2-n)}\right )}{a (4-n)}+\frac {i (a+i a \tan (c+d x))^n (e \sec (c+d x))^{-n-4}}{d (4-n)}\) |
\(\Big \downarrow \) 3042 |
\(\displaystyle \frac {4 \left (\frac {3 \left (-\frac {2 \int (e \sec (c+d x))^{-n-4} (i \tan (c+d x) a+a)^{n+3}dx}{a n}-\frac {i (a+i a \tan (c+d x))^{n+2} (e \sec (c+d x))^{-n-4}}{d n}\right )}{a (2-n)}+\frac {i (a+i a \tan (c+d x))^{n+1} (e \sec (c+d x))^{-n-4}}{d (2-n)}\right )}{a (4-n)}+\frac {i (a+i a \tan (c+d x))^n (e \sec (c+d x))^{-n-4}}{d (4-n)}\) |
\(\Big \downarrow \) 3985 |
\(\displaystyle \frac {4 \left (\frac {3 \left (-\frac {2 \left (-\frac {\int (e \sec (c+d x))^{-n-4} (i \tan (c+d x) a+a)^{n+4}dx}{a (n+2)}-\frac {i (a+i a \tan (c+d x))^{n+3} (e \sec (c+d x))^{-n-4}}{d (n+2)}\right )}{a n}-\frac {i (a+i a \tan (c+d x))^{n+2} (e \sec (c+d x))^{-n-4}}{d n}\right )}{a (2-n)}+\frac {i (a+i a \tan (c+d x))^{n+1} (e \sec (c+d x))^{-n-4}}{d (2-n)}\right )}{a (4-n)}+\frac {i (a+i a \tan (c+d x))^n (e \sec (c+d x))^{-n-4}}{d (4-n)}\) |
\(\Big \downarrow \) 3042 |
\(\displaystyle \frac {4 \left (\frac {3 \left (-\frac {2 \left (-\frac {\int (e \sec (c+d x))^{-n-4} (i \tan (c+d x) a+a)^{n+4}dx}{a (n+2)}-\frac {i (a+i a \tan (c+d x))^{n+3} (e \sec (c+d x))^{-n-4}}{d (n+2)}\right )}{a n}-\frac {i (a+i a \tan (c+d x))^{n+2} (e \sec (c+d x))^{-n-4}}{d n}\right )}{a (2-n)}+\frac {i (a+i a \tan (c+d x))^{n+1} (e \sec (c+d x))^{-n-4}}{d (2-n)}\right )}{a (4-n)}+\frac {i (a+i a \tan (c+d x))^n (e \sec (c+d x))^{-n-4}}{d (4-n)}\) |
\(\Big \downarrow \) 3969 |
\(\displaystyle \frac {i (a+i a \tan (c+d x))^n (e \sec (c+d x))^{-n-4}}{d (4-n)}+\frac {4 \left (\frac {i (a+i a \tan (c+d x))^{n+1} (e \sec (c+d x))^{-n-4}}{d (2-n)}+\frac {3 \left (-\frac {i (a+i a \tan (c+d x))^{n+2} (e \sec (c+d x))^{-n-4}}{d n}-\frac {2 \left (\frac {i (a+i a \tan (c+d x))^{n+4} (e \sec (c+d x))^{-n-4}}{a d (n+2) (n+4)}-\frac {i (a+i a \tan (c+d x))^{n+3} (e \sec (c+d x))^{-n-4}}{d (n+2)}\right )}{a n}\right )}{a (2-n)}\right )}{a (4-n)}\) |
(I*(e*Sec[c + d*x])^(-4 - n)*(a + I*a*Tan[c + d*x])^n)/(d*(4 - n)) + (4*(( I*(e*Sec[c + d*x])^(-4 - n)*(a + I*a*Tan[c + d*x])^(1 + n))/(d*(2 - n)) + (3*(((-I)*(e*Sec[c + d*x])^(-4 - n)*(a + I*a*Tan[c + d*x])^(2 + n))/(d*n) - (2*(((-I)*(e*Sec[c + d*x])^(-4 - n)*(a + I*a*Tan[c + d*x])^(3 + n))/(d*( 2 + n)) + (I*(e*Sec[c + d*x])^(-4 - n)*(a + I*a*Tan[c + d*x])^(4 + n))/(a* d*(2 + n)*(4 + n))))/(a*n)))/(a*(2 - n))))/(a*(4 - n))
3.5.83.3.1 Defintions of rubi rules used
Int[((d_.)*sec[(e_.) + (f_.)*(x_)])^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*( x_)])^(n_), x_Symbol] :> Simp[b*(d*Sec[e + f*x])^m*((a + b*Tan[e + f*x])^n/ (a*f*m)), x] /; FreeQ[{a, b, d, e, f, m, n}, x] && EqQ[a^2 + b^2, 0] && EqQ [Simplify[m + n], 0]
Int[((d_.)*sec[(e_.) + (f_.)*(x_)])^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*( x_)])^(n_), x_Symbol] :> Simp[a*(d*Sec[e + f*x])^m*((a + b*Tan[e + f*x])^n/ (b*f*(m + 2*n))), x] + Simp[Simplify[m + n]/(a*(m + 2*n)) Int[(d*Sec[e + f*x])^m*(a + b*Tan[e + f*x])^(n + 1), x], x] /; FreeQ[{a, b, d, e, f, m, n} , x] && EqQ[a^2 + b^2, 0] && ILtQ[Simplify[m + n], 0] && NeQ[m + 2*n, 0]
Result contains higher order function than in optimal. Order 9 vs. order 3.
Time = 6.43 (sec) , antiderivative size = 4331, normalized size of antiderivative = 16.10
-1/16*I/(n-4)/d*a^n/(e^n)/e^4*exp(I*(d*x+c))^n*exp(-1/2*I*(-csgn(I*a*exp(2 *I*(d*x+c))/(exp(2*I*(d*x+c))+1))^2*csgn(I*a)*Pi*n+csgn(I/(exp(2*I*(d*x+c) )+1)*exp(2*I*(d*x+c)))*csgn(I*a*exp(2*I*(d*x+c))/(exp(2*I*(d*x+c))+1))*csg n(I*a)*Pi*n+csgn(I*a*exp(2*I*(d*x+c))/(exp(2*I*(d*x+c))+1))^3*Pi*n-csgn(I/ (exp(2*I*(d*x+c))+1)*exp(2*I*(d*x+c)))*csgn(I*a*exp(2*I*(d*x+c))/(exp(2*I* (d*x+c))+1))^2*Pi*n-n*Pi*csgn(I*e*exp(I*(d*x+c))/(exp(2*I*(d*x+c))+1))^3+n *Pi*csgn(I*e)*csgn(I*e*exp(I*(d*x+c))/(exp(2*I*(d*x+c))+1))^2+n*Pi*csgn(I* exp(I*(d*x+c))/(exp(2*I*(d*x+c))+1))*csgn(I*e*exp(I*(d*x+c))/(exp(2*I*(d*x +c))+1))^2-n*Pi*csgn(I*e)*csgn(I*exp(I*(d*x+c))/(exp(2*I*(d*x+c))+1))*csgn (I*e*exp(I*(d*x+c))/(exp(2*I*(d*x+c))+1))+Pi*csgn(I*exp(2*I*(d*x+c)))^3*n- 2*Pi*csgn(I*exp(2*I*(d*x+c)))^2*csgn(I*exp(I*(d*x+c)))*n+Pi*csgn(I*exp(2*I *(d*x+c)))*csgn(I*exp(I*(d*x+c)))^2*n-csgn(I/(exp(2*I*(d*x+c))+1)*exp(2*I* (d*x+c)))^2*Pi*csgn(I*exp(2*I*(d*x+c)))*n+csgn(I/(exp(2*I*(d*x+c))+1)*exp( 2*I*(d*x+c)))*Pi*csgn(I/(exp(2*I*(d*x+c))+1))*csgn(I*exp(2*I*(d*x+c)))*n-n *Pi*csgn(I/(exp(2*I*(d*x+c))+1))*csgn(I*exp(I*(d*x+c)))*csgn(I*exp(I*(d*x+ c))/(exp(2*I*(d*x+c))+1))+n*Pi*csgn(I*exp(I*(d*x+c)))*csgn(I*exp(I*(d*x+c) )/(exp(2*I*(d*x+c))+1))^2+csgn(I/(exp(2*I*(d*x+c))+1)*exp(2*I*(d*x+c)))^3* Pi*n-csgn(I/(exp(2*I*(d*x+c))+1)*exp(2*I*(d*x+c)))^2*Pi*csgn(I/(exp(2*I*(d *x+c))+1))*n+n*Pi*csgn(I/(exp(2*I*(d*x+c))+1))*csgn(I*exp(I*(d*x+c))/(exp( 2*I*(d*x+c))+1))^2-n*Pi*csgn(I*exp(I*(d*x+c))/(exp(2*I*(d*x+c))+1))^3+8...
Time = 0.25 (sec) , antiderivative size = 335, normalized size of antiderivative = 1.25 \[ \int (e \sec (c+d x))^{-4-n} (a+i a \tan (c+d x))^n \, dx=\frac {{\left (-i \, n^{4} - 4 i \, n^{3} + 4 i \, n^{2} + {\left (-i \, n^{4} + 4 i \, n^{3} + 4 i \, n^{2} - 16 i \, n\right )} e^{\left (8 i \, d x + 8 i \, c\right )} - 4 \, {\left (i \, n^{4} - 2 i \, n^{3} - 16 i \, n^{2} + 32 i \, n\right )} e^{\left (6 i \, d x + 6 i \, c\right )} - 6 \, {\left (i \, n^{4} - 20 i \, n^{2} + 64 i\right )} e^{\left (4 i \, d x + 4 i \, c\right )} - 4 \, {\left (i \, n^{4} + 2 i \, n^{3} - 16 i \, n^{2} - 32 i \, n\right )} e^{\left (2 i \, d x + 2 i \, c\right )} + 16 i \, n\right )} \left (\frac {2 \, e e^{\left (i \, d x + i \, c\right )}}{e^{\left (2 i \, d x + 2 i \, c\right )} + 1}\right )^{-n - 4} e^{\left (i \, d n x + i \, c n + n \log \left (\frac {2 \, e e^{\left (i \, d x + i \, c\right )}}{e^{\left (2 i \, d x + 2 i \, c\right )} + 1}\right ) + n \log \left (\frac {a}{e}\right )\right )}}{d n^{5} - 20 \, d n^{3} + 64 \, d n + {\left (d n^{5} - 20 \, d n^{3} + 64 \, d n\right )} e^{\left (8 i \, d x + 8 i \, c\right )} + 4 \, {\left (d n^{5} - 20 \, d n^{3} + 64 \, d n\right )} e^{\left (6 i \, d x + 6 i \, c\right )} + 6 \, {\left (d n^{5} - 20 \, d n^{3} + 64 \, d n\right )} e^{\left (4 i \, d x + 4 i \, c\right )} + 4 \, {\left (d n^{5} - 20 \, d n^{3} + 64 \, d n\right )} e^{\left (2 i \, d x + 2 i \, c\right )}} \]
(-I*n^4 - 4*I*n^3 + 4*I*n^2 + (-I*n^4 + 4*I*n^3 + 4*I*n^2 - 16*I*n)*e^(8*I *d*x + 8*I*c) - 4*(I*n^4 - 2*I*n^3 - 16*I*n^2 + 32*I*n)*e^(6*I*d*x + 6*I*c ) - 6*(I*n^4 - 20*I*n^2 + 64*I)*e^(4*I*d*x + 4*I*c) - 4*(I*n^4 + 2*I*n^3 - 16*I*n^2 - 32*I*n)*e^(2*I*d*x + 2*I*c) + 16*I*n)*(2*e*e^(I*d*x + I*c)/(e^ (2*I*d*x + 2*I*c) + 1))^(-n - 4)*e^(I*d*n*x + I*c*n + n*log(2*e*e^(I*d*x + I*c)/(e^(2*I*d*x + 2*I*c) + 1)) + n*log(a/e))/(d*n^5 - 20*d*n^3 + 64*d*n + (d*n^5 - 20*d*n^3 + 64*d*n)*e^(8*I*d*x + 8*I*c) + 4*(d*n^5 - 20*d*n^3 + 64*d*n)*e^(6*I*d*x + 6*I*c) + 6*(d*n^5 - 20*d*n^3 + 64*d*n)*e^(4*I*d*x + 4 *I*c) + 4*(d*n^5 - 20*d*n^3 + 64*d*n)*e^(2*I*d*x + 2*I*c))
\[ \int (e \sec (c+d x))^{-4-n} (a+i a \tan (c+d x))^n \, dx=\int \left (e \sec {\left (c + d x \right )}\right )^{- n - 4} \left (i a \left (\tan {\left (c + d x \right )} - i\right )\right )^{n}\, dx \]
Time = 0.82 (sec) , antiderivative size = 435, normalized size of antiderivative = 1.62 \[ \int (e \sec (c+d x))^{-4-n} (a+i a \tan (c+d x))^n \, dx=\frac {{\left (-i \, a^{n} n^{4} + 4 i \, a^{n} n^{3} + 4 i \, a^{n} n^{2} - 16 i \, a^{n} n\right )} \cos \left ({\left (d x + c\right )} {\left (n + 4\right )}\right ) - 4 \, {\left (i \, a^{n} n^{4} - 2 i \, a^{n} n^{3} - 16 i \, a^{n} n^{2} + 32 i \, a^{n} n\right )} \cos \left ({\left (d x + c\right )} {\left (n + 2\right )}\right ) - 4 \, {\left (i \, a^{n} n^{4} + 2 i \, a^{n} n^{3} - 16 i \, a^{n} n^{2} - 32 i \, a^{n} n\right )} \cos \left ({\left (d x + c\right )} {\left (n - 2\right )}\right ) + {\left (-i \, a^{n} n^{4} - 4 i \, a^{n} n^{3} + 4 i \, a^{n} n^{2} + 16 i \, a^{n} n\right )} \cos \left ({\left (d x + c\right )} {\left (n - 4\right )}\right ) - 6 \, {\left (i \, a^{n} n^{4} - 20 i \, a^{n} n^{2} + 64 i \, a^{n}\right )} \cos \left ({\left (d x + c\right )} n\right ) + {\left (a^{n} n^{4} - 4 \, a^{n} n^{3} - 4 \, a^{n} n^{2} + 16 \, a^{n} n\right )} \sin \left ({\left (d x + c\right )} {\left (n + 4\right )}\right ) + 4 \, {\left (a^{n} n^{4} - 2 \, a^{n} n^{3} - 16 \, a^{n} n^{2} + 32 \, a^{n} n\right )} \sin \left ({\left (d x + c\right )} {\left (n + 2\right )}\right ) + 4 \, {\left (a^{n} n^{4} + 2 \, a^{n} n^{3} - 16 \, a^{n} n^{2} - 32 \, a^{n} n\right )} \sin \left ({\left (d x + c\right )} {\left (n - 2\right )}\right ) + {\left (a^{n} n^{4} + 4 \, a^{n} n^{3} - 4 \, a^{n} n^{2} - 16 \, a^{n} n\right )} \sin \left ({\left (d x + c\right )} {\left (n - 4\right )}\right ) + 6 \, {\left (a^{n} n^{4} - 20 \, a^{n} n^{2} + 64 \, a^{n}\right )} \sin \left ({\left (d x + c\right )} n\right )}{16 \, {\left (e^{n + 4} n^{5} - 20 \, e^{n + 4} n^{3} + 64 \, e^{n + 4} n\right )} d} \]
1/16*((-I*a^n*n^4 + 4*I*a^n*n^3 + 4*I*a^n*n^2 - 16*I*a^n*n)*cos((d*x + c)* (n + 4)) - 4*(I*a^n*n^4 - 2*I*a^n*n^3 - 16*I*a^n*n^2 + 32*I*a^n*n)*cos((d* x + c)*(n + 2)) - 4*(I*a^n*n^4 + 2*I*a^n*n^3 - 16*I*a^n*n^2 - 32*I*a^n*n)* cos((d*x + c)*(n - 2)) + (-I*a^n*n^4 - 4*I*a^n*n^3 + 4*I*a^n*n^2 + 16*I*a^ n*n)*cos((d*x + c)*(n - 4)) - 6*(I*a^n*n^4 - 20*I*a^n*n^2 + 64*I*a^n)*cos( (d*x + c)*n) + (a^n*n^4 - 4*a^n*n^3 - 4*a^n*n^2 + 16*a^n*n)*sin((d*x + c)* (n + 4)) + 4*(a^n*n^4 - 2*a^n*n^3 - 16*a^n*n^2 + 32*a^n*n)*sin((d*x + c)*( n + 2)) + 4*(a^n*n^4 + 2*a^n*n^3 - 16*a^n*n^2 - 32*a^n*n)*sin((d*x + c)*(n - 2)) + (a^n*n^4 + 4*a^n*n^3 - 4*a^n*n^2 - 16*a^n*n)*sin((d*x + c)*(n - 4 )) + 6*(a^n*n^4 - 20*a^n*n^2 + 64*a^n)*sin((d*x + c)*n))/((e^(n + 4)*n^5 - 20*e^(n + 4)*n^3 + 64*e^(n + 4)*n)*d)
\[ \int (e \sec (c+d x))^{-4-n} (a+i a \tan (c+d x))^n \, dx=\int { \left (e \sec \left (d x + c\right )\right )^{-n - 4} {\left (i \, a \tan \left (d x + c\right ) + a\right )}^{n} \,d x } \]
Time = 11.48 (sec) , antiderivative size = 511, normalized size of antiderivative = 1.90 \[ \int (e \sec (c+d x))^{-4-n} (a+i a \tan (c+d x))^n \, dx=\frac {\left (2\,{\sin \left (2\,c+2\,d\,x\right )}^2+\sin \left (4\,c+4\,d\,x\right )\,1{}\mathrm {i}-1\right )\,\left (\frac {{\left (a-\frac {a\,\sin \left (c+d\,x\right )\,1{}\mathrm {i}}{2\,{\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2-1}\right )}^n\,\left (-n^3-4\,n^2+4\,n+16\right )}{d\,\left (n^4\,1{}\mathrm {i}-n^2\,20{}\mathrm {i}+64{}\mathrm {i}\right )}+\frac {4\,{\left (a-\frac {a\,\sin \left (c+d\,x\right )\,1{}\mathrm {i}}{2\,{\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2-1}\right )}^n\,\left (-2\,{\sin \left (c+d\,x\right )}^2+\sin \left (2\,c+2\,d\,x\right )\,1{}\mathrm {i}+1\right )\,\left (-n^3-2\,n^2+16\,n+32\right )}{d\,\left (n^4\,1{}\mathrm {i}-n^2\,20{}\mathrm {i}+64{}\mathrm {i}\right )}+\frac {{\left (a-\frac {a\,\sin \left (c+d\,x\right )\,1{}\mathrm {i}}{2\,{\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2-1}\right )}^n\,\left (-2\,{\sin \left (4\,c+4\,d\,x\right )}^2+\sin \left (8\,c+8\,d\,x\right )\,1{}\mathrm {i}+1\right )\,\left (-n^3+4\,n^2+4\,n-16\right )}{d\,\left (n^4\,1{}\mathrm {i}-n^2\,20{}\mathrm {i}+64{}\mathrm {i}\right )}+\frac {4\,{\left (a-\frac {a\,\sin \left (c+d\,x\right )\,1{}\mathrm {i}}{2\,{\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2-1}\right )}^n\,\left (-2\,{\sin \left (3\,c+3\,d\,x\right )}^2+\sin \left (6\,c+6\,d\,x\right )\,1{}\mathrm {i}+1\right )\,\left (-n^3+2\,n^2+16\,n-32\right )}{d\,\left (n^4\,1{}\mathrm {i}-n^2\,20{}\mathrm {i}+64{}\mathrm {i}\right )}-\frac {{\left (a-\frac {a\,\sin \left (c+d\,x\right )\,1{}\mathrm {i}}{2\,{\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2-1}\right )}^n\,\left (-2\,{\sin \left (2\,c+2\,d\,x\right )}^2+\sin \left (4\,c+4\,d\,x\right )\,1{}\mathrm {i}+1\right )\,\left (6\,n^4-120\,n^2+384\right )}{d\,n\,\left (n^4\,1{}\mathrm {i}-n^2\,20{}\mathrm {i}+64{}\mathrm {i}\right )}\right )}{16\,{\left (-\frac {e}{2\,{\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2-1}\right )}^{n+4}\,{\left ({\sin \left (c+d\,x\right )}^2-1\right )}^2} \]
((sin(4*c + 4*d*x)*1i + 2*sin(2*c + 2*d*x)^2 - 1)*(((a - (a*sin(c + d*x)*1 i)/(2*sin(c/2 + (d*x)/2)^2 - 1))^n*(4*n - 4*n^2 - n^3 + 16))/(d*(n^4*1i - n^2*20i + 64i)) + (4*(a - (a*sin(c + d*x)*1i)/(2*sin(c/2 + (d*x)/2)^2 - 1) )^n*(sin(2*c + 2*d*x)*1i - 2*sin(c + d*x)^2 + 1)*(16*n - 2*n^2 - n^3 + 32) )/(d*(n^4*1i - n^2*20i + 64i)) + ((a - (a*sin(c + d*x)*1i)/(2*sin(c/2 + (d *x)/2)^2 - 1))^n*(sin(8*c + 8*d*x)*1i - 2*sin(4*c + 4*d*x)^2 + 1)*(4*n + 4 *n^2 - n^3 - 16))/(d*(n^4*1i - n^2*20i + 64i)) + (4*(a - (a*sin(c + d*x)*1 i)/(2*sin(c/2 + (d*x)/2)^2 - 1))^n*(sin(6*c + 6*d*x)*1i - 2*sin(3*c + 3*d* x)^2 + 1)*(16*n + 2*n^2 - n^3 - 32))/(d*(n^4*1i - n^2*20i + 64i)) - ((a - (a*sin(c + d*x)*1i)/(2*sin(c/2 + (d*x)/2)^2 - 1))^n*(sin(4*c + 4*d*x)*1i - 2*sin(2*c + 2*d*x)^2 + 1)*(6*n^4 - 120*n^2 + 384))/(d*n*(n^4*1i - n^2*20i + 64i))))/(16*(-e/(2*sin(c/2 + (d*x)/2)^2 - 1))^(n + 4)*(sin(c + d*x)^2 - 1)^2)